<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Searchresult extends CI_Controller {

	public function index()
	{
		//modell
		$this->load->model('Products_model');
		$data['products_model'] = $this->Products_model;
		$data['selected_category_id'] = -1;

		
		
		$queryText = 'SELECT * from products where 
					 description REGEXP ".*'.$this->input->post('search').'" OR
					 name REGEXP ".*'.$this->input->post('search').'"';
		
		$query = $this->db->query($queryText);
		
		$data['searchResult'] = $query->result();
		
		//view
		$this->load->view('head');
		$this->load->view('header', array('activeLink' => "none"));
		$this->load->view('searchresult', $data);
        $this->load->view('footer');   
	}
}